package com.songtech.demo.controller;

import java.util.List;

import javax.servlet.http.HttpServletRequest;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import com.songtech.demo.model.Demo;
import com.songtech.demo.service.DemoService;

@Controller
public class DemoController {
	@Autowired
	private DemoService demoService;
	
	Logger  logger = LoggerFactory.getLogger(DemoController.class);
	
	
	@ResponseBody
	@RequestMapping("/test")
	@SuppressWarnings("unused")
	public String  addCache(HttpServletRequest request) {
		List<Demo> users = demoService.getAll();
		Demo user = demoService.getOne(1L);
		System.out.println("若下面没出现“无缓存的时候调用”字样且能打印出数据表示测试成功"); 
		return "ok";
	}
	
	
	
	@RequestMapping("/test2")  
    @ResponseBody  
    public String testCache(){  
		List<Demo> users = demoService.getAll();
		Demo user = demoService.getOne(1L);
        System.out.println("我这里没执行查询");  
        System.out.println("user size:"+"/"+users.size());
        System.out.println("user:"+"/"+user.getNickName()+"/"+user.getPassWord());  
        return "ok";  
    }  
	
	@RequestMapping("/getAll")  
    @ResponseBody  
	public String getAll(){
		List<Demo> demoList = demoService.getAll();
		System.out.println("demo size:"+"/"+demoList.size());
		return "ok";
	}
    
}
